package com.jomoo.css.common.core.hibernate.inspector;

import lombok.extern.slf4j.Slf4j;
import org.hibernate.CallbackException;
import org.hibernate.EmptyInterceptor;
import org.hibernate.EntityMode;
import org.hibernate.Transaction;
import org.hibernate.type.Type;

import java.io.Serializable;
import java.util.Iterator;

@Slf4j
public class LingHibernateInspector extends EmptyInterceptor {

    @Override
    public boolean onLoad(Object o, Serializable serializable, Object[] objects, String[] strings, Type[] types) throws CallbackException {
        return true;
    }

    @Override
    public boolean onFlushDirty(Object o, Serializable serializable, Object[] objects, Object[] objects1, String[] strings, Type[] types) throws CallbackException {
        return true;
    }

    @Override
    public boolean onSave(Object o, Serializable serializable, Object[] objects, String[] strings, Type[] types) throws CallbackException {
        return true;
    }

    @Override
    public void onDelete(Object o, Serializable serializable, Object[] objects, String[] strings, Type[] types) throws CallbackException {

    }

    @Override
    public void onCollectionRecreate(Object o, Serializable serializable) throws CallbackException {

    }

    @Override
    public void onCollectionRemove(Object o, Serializable serializable) throws CallbackException {

    }

    @Override
    public void onCollectionUpdate(Object o, Serializable serializable) throws CallbackException {

    }

    @Override
    public void preFlush(Iterator iterator) throws CallbackException {
        System.out.println(1);
    }

    @Override
    public void postFlush(Iterator iterator) throws CallbackException {
        System.out.println(2);
    }

    @Override
    public Boolean isTransient(Object o) {
        return null;
    }

    @Override
    public int[] findDirty(Object o, Serializable serializable, Object[] objects, Object[] objects1, String[] strings, Type[] types) {
        return new int[0];
    }

    @Override
    public Object instantiate(String s, EntityMode entityMode, Serializable serializable) throws CallbackException {
        return null;
    }

    @Override
    public String getEntityName(Object o) throws CallbackException {
        return null;
    }

    @Override
    public Object getEntity(String s, Serializable serializable) throws CallbackException {
        return null;
    }

    @Override
    public void afterTransactionBegin(Transaction transaction) {

    }

    @Override
    public void beforeTransactionCompletion(Transaction transaction) {

    }

    @Override
    public void afterTransactionCompletion(Transaction transaction) {

    }

    @Override
    public String onPrepareStatement(String s) {
        log.info(s);
        return null;
    }
}
